package com.example.zookeeperlock.testcase;

import com.example.zookeeperlock.highlock.impl.HighQualityLock;
import com.example.zookeeperlock.highlock.impl.SimpleZkLock;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: zhangrongqing
 * @Date: 2020/9/1 17:28
 */
public class HighLockCase {

    ExecutorService executorService = Executors.newFixedThreadPool(10);


    public void testHighLock() {

        for (int i = 0; i < 10; i++) {
            executorService.submit(() -> {
                HighQualityLock highQualityLock = new HighQualityLock();

                highQualityLock.getLock();

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                highQualityLock.releaseLock();
            });
        }

        executorService.shutdown();
    }


    public static void main(String[] args) {
        new HighLockCase().testHighLock();
    }
}
